package com.nts.pmchelperdemo2.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nts.pmchelperdemo2.entity.Order;
import com.nts.pmchelperdemo2.mapper.OrderMapper;
import com.nts.pmchelperdemo2.service.OrderService;
import com.nts.pmchelperdemo2.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper,Order> implements OrderService {
    @Autowired
    private ScheduleService scheduleService;

    @Override
    @Transactional
    public boolean saveOrder(Order order){
    order.setOrderNo("ORD"+System.currentTimeMillis());
    order.setStatus(0);
    order.setCreateTime(LocalDateTime.now());
    boolean saved = save(order);
    if(saved){
        scheduleService.adjustTomorrowSchedule();;
    }
    return saved;
    }

}
